<?php
include("../../../mainfile.php");
include_once(XOOPS_ROOT_PATH."/class/xoopsmodule.php");
include(XOOPS_ROOT_PATH."/include/cp_functions.php");
include("../include/functions.inc.php");

$xoopsOption['template_main'] = 'administracion.html';

if ( $xoopsUser ) 
{
	$xoopsModule = XoopsModule::getByDirname("modulopsa"); /*RECUERDA PONER EL NOMBRE DE TU MODULO AQUI*/
	if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) 
	{ 
		redirect_header(XOOPS_URL."/",3,_NOPERM);
		exit();
	}
} else 
{
	redirect_header(XOOPS_URL."/",3,_NOPERM);
	exit();
}

if ( file_exists("../language/".$xoopsConfig['language']."/admin.php") ) 
{
	include("../language/".$xoopsConfig['language']."/admin.php");
} else 
{
	include("../language/english/admin.php");
}

global $xoopsModule;

//xoops_cp_header();  
require(XOOPS_ROOT_PATH . '/header.php');

$nuevos = 2;

if (isset($_POST['submit'])) {
    
    $json_output = consumirServicioPredios();
//    var_dump($json_output); 
    $predios = transformarPredioJSON($json_output, $xoopsDB);
//    var_dump($predios);
    
    if (empty($predios)){
        $nuevos = 0;
    }else{
        $nuevos = 1;
    }    
    $xoopsTpl->assign('predios', $predios);
    
}
$xoopsTpl->assign('nuevos', $nuevos);
//xoops_cp_footer();  
require(XOOPS_ROOT_PATH . '/footer.php');

?>